import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '~': path.resolve(__dirname, './'),
      '@': path.resolve(__dirname, 'src')
    },
  },
  server: {
    port: process.env.VITE_PORT,
    open: true,
    https: false,
    proxy: {
      '/api': {
        target: 'http://backend-api-02.newbee.Itd/manage-api/v1', // 凡是遇到/api 的路径请求，都映射到 target 属性
        changeOrigin: true,
        rewrite: path => path.replace(/^\api/, ''), // 重写 api 为空，就是去掉它
      },
    },
  },
})
